//
//  QFStatus.swift
//  sinaWeibo
//
//  Created by apple on 16/3/5.
//  Copyright © 2016年 Qifeng Yan. All rights reserved.
//

import UIKit

class QFStatus: NSObject {

    /// 微博创建时间
    var created_at: String?
    
    /// 微博ID
    var id: Int = 0
    
    /// 微博内容
    var text: String?
    
    /// 微博来源
    var source: String?
    
    /// 微博配图
    var pic_urls: [[String: AnyObject]]?
    
    /// 转发数
    var reposts_count: Int = 0
    
    /// 评论数
    var comments_count: Int = 0
    
    /// 表态数
    var attitudes_count: Int = 0
    
    /// 用户信息
    var user: QFUser?
    
    /// 字典转模型
    init(dict: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        // 拦截用户信息 进行赋值 字典转模型
        if key == "user" {
            if let dict = value as? [String: AnyObject] {
                user = QFUser(dict: dict)
            }
            return
        }
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    
    // MARK: - 打印数据模型
    override var description: String {
        let keys = ["created_at", "id", "text", "source", "pic_urls", "reposts_count", "comments_count", "attitudes_count", "user"]
       
        return "\n\t微博模型：\(dictionaryWithValuesForKeys(keys).description)"
    }
}
